#ifndef __LOGGER_H__
#define __LOGGER_H__

#include <fstream>
#include <boost/shared_ptr.hpp>
#include <boost/make_shared.hpp>
#include <boost/core/null_deleter.hpp>
#include <boost/log/core.hpp>
#include <boost/log/trivial.hpp>
#include <boost/log/expressions.hpp>
#include <boost/log/sinks/sync_frontend.hpp>
#include <boost/log/sinks/text_ostream_backend.hpp>
#include <boost/log/sources/severity_logger.hpp>
#include <boost/log/sources/record_ostream.hpp>
#include <boost/log/utility/setup/common_attributes.hpp>
#include <boost/log/support/date_time.hpp>
#include <boost/thread/thread.hpp>
#include <boost/log/attributes/scoped_attribute.hpp>
#include <boost/smart_ptr/shared_ptr.hpp>
#include <boost/log/attributes.hpp>

namespace logging = boost::log;
namespace src = boost::log::sources;
namespace expr = boost::log::expressions;
namespace sinks = boost::log::sinks;
namespace keywords = boost::log::keywords;
namespace attrs = boost::log::attributes;

using namespace logging::trivial;

using boost::shared_ptr;

typedef sinks::synchronous_sink< sinks::text_ostream_backend > text_sink;

namespace ECG{
    namespace Utitl
    {
        class Logger{
        public:
            boost::shared_ptr< text_sink > sink;
            static Logger* instance();
            static void destroy();   
            src::severity_logger< severity_level > lg;
        private:
            static Logger *m_logger;
            Logger();
            ~Logger();
        };

    }
}

/**
 *  set the log print level,if (print level) < (setting level),we will
 *  not print the message
*/
#define set_log_level(level)	\
({\
	core::get()->set_filter\
    (\
        trivial::severity >= level\
    );\
})


/**
 * print function define in macro,you can call this to print message in
 * defferent level
*/
#define log_trace()  BOOST_LOG_SEV(ECG::Utitl::Logger::instance()->lg, trace)
#define log_debug()  BOOST_LOG_SEV(ECG::Utitl::Logger::instance()->lg, debug)
#define log_info()   BOOST_LOG_SEV(ECG::Utitl::Logger::instance()->lg, info)
#define log_warn()   BOOST_LOG_SEV(ECG::Utitl::Logger::instance()->lg, warning)
#define log_error()  BOOST_LOG_SEV(ECG::Utitl::Logger::instance()->lg, error)
#define log_fatal()  BOOST_LOG_SEV(ECG::Utitl::Logger::instance()->lg, fatal)

#endif //__LOGGER_H__


